String Literal (SL)

Description:

If your project can be internationalized, you should avoid using hard coded string and character literals, and keep them in external resources instead. This audit helps to find such unsafe literals.

You can customize the filter by checking the Ignore white spaces and Ignore digits options in the audit properties.

The Suppression comment option allows you to define a comment marker pattern. Comment markers are used to distinguish non-translatable strings.

The number entered in the place of the question mark (?) in the marker pattern indicates the string that should not be translated in the case where there are several strings on a single line (for example, $NON-NLS-1$ will match the marker pattern $NON-NLS-?$).

Incorrect:

public const String msgError = "Error";

Correct:

public const String msgError = resourceManager.GetString("msg.error"); // $NON-NLS-1$